package com.woniuxy.countweb.controller;


import com.woniuxy.core.model.Result;
import com.woniuxy.core.util.MyJwtUtil;
import com.woniuxy.countdao.model.FlowChart;
import com.woniuxy.countmodel.dto.FlowChartDto;
import com.woniuxy.countservice.service.FlowChartService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 冉杰
 * @since 2024-01-15
 */
@RestController
@RequestMapping("/flowChart")
@Api(tags = {"流水统计接口"})
public class FlowChartController {
    @Autowired
    private FlowChartService flowChartService;
    @ApiOperation("商家年月销售额统计接口")
    @GetMapping("/add.venue")
    public Result add(@RequestHeader String token){
        Integer venueId = MyJwtUtil.getVenueIdByKey(token, "venueId");
        flowChartService.add(venueId);
        return Result.success("商家流水统计成功");
    }
    @ApiOperation("根据id查询销售额统计接口")
    @GetMapping("/look")
    public Result look(Integer chartId){
        FlowChart flowChart = flowChartService.look(chartId);
        return Result.success("根据id查询商家流水成功",flowChart);
    }
    @ApiOperation("商家查询自己的月销售额统计接口")
    @GetMapping("/venueLook.venue")
    public Result venueLook(Integer year,Integer month, @RequestHeader String token){
        Integer venueId = MyJwtUtil.getVenueIdByKey(token, "venueId");
        FlowChartDto dtos = flowChartService.venueLook(year,month,venueId);
        return Result.success("根据id查询商家流水成功",dtos);
    }


}

